package com.quanshu.shop.person.adapter;

import android.support.annotation.Nullable;
import android.widget.ImageView;

import com.chad.library.adapter.base.BaseQuickAdapter;
import com.chad.library.adapter.base.BaseViewHolder;
import com.quanshu.exchange.R;
import com.quanshu.shop.person.entity.MySelectAddressEntity;

import java.util.List;

/**
 * 作者  李哲
 * 创建时间 2018/7/20
 * 邮箱 lizhetongliao@163.com
 * 说明
 **/
public class AddressAdapter extends BaseQuickAdapter<MySelectAddressEntity, BaseViewHolder> {
    public AddressAdapter(@Nullable List<MySelectAddressEntity> data) {
        super(R.layout.item_address, data);
    }

    @Override
    protected void convert(BaseViewHolder helper, MySelectAddressEntity item) {
        helper.setText(R.id.textView2, item.getAddressListEntity().getAccept_name());
        helper.setText(R.id.textView3, item.getAddressListEntity().getMobile());
        helper.setText(R.id.textView4, item.getAddressListEntity().getProvince_val() + item.getAddressListEntity().getCity_val() + item.getAddressListEntity().getArea_val() + item.getAddressListEntity().getAddress());
        ImageView imageView = helper.getView(R.id.img1);
        if (Integer.parseInt(item.getAddressListEntity().getIs_default()) == 1) {
            imageView.setImageResource(R.drawable.icon_selected_1_2_0);
            helper.setText(R.id.txt1, "默认地址");
        } else {
            imageView.setImageResource(R.drawable.icon_unselected_1_2_0);
            helper.setText(R.id.txt1, "设为默认地址");
        }
        if (item.isSelect()) {
            helper.setVisible(R.id.textView5, false);
            helper.setVisible(R.id.ImgView5, true);
        } else {
            helper.setVisible(R.id.textView5, true);
            helper.setVisible(R.id.ImgView5, false);
        }

        helper.addOnClickListener(R.id.set_default);
        helper.addOnClickListener(R.id.fl5);
        helper.addOnClickListener(R.id.ll_edit);
        helper.addOnClickListener(R.id.ll_delete);
    }
}
